package org.example.redo.controller;

import org.example.redo.constant.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/producer")
public class Producer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/work/{txt}")
    public String work(@PathVariable("txt")String txt) {
        rabbitTemplate.convertAndSend("", Constants.WORK_QUEUE,txt);
        return "work ok";
    }

    @RequestMapping("/direct/{meg}")
    public String direct(@PathVariable("meg")String meg) {
        rabbitTemplate.convertAndSend(Constants.DIRECT_EXCHANGE, "a1", meg);
        return "direct ok";
    }

}
